package glazedlists.chapter2;

import ca.odell.glazedlists.gui.TableFormat;
import ca.odell.issuezilla.Issue;

public class IssueTableFormat implements TableFormat<Issue> {

    @Override
    public int getColumnCount() {
        return 7;
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "ID";
            case 1:
                return "Type";
            case 2:
                return "Priority";
            case 3:
                return "State";
            case 4:
                return "Result";
            case 5:
                return "Summary";
            case 6:
                return "Reporter";
        }
        throw new IllegalStateException("Unexpected column: " + column);
    }

    @Override
    public Object getColumnValue(Issue issue, int column) {
        switch (column) {
            case 0:
                return issue.getId();
            case 1:
                return issue.getIssueType();
            case 2:
                return issue.getPriority();
            case 3:
                return issue.getStatus();
            case 4:
                return issue.getResolution();
            case 5:
                return issue.getShortDescription();
            case 6:
                return issue.getReporter();
        }
        throw new IllegalStateException("Unexpected column: " + column);
    }
}
